﻿<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Cart.aspx.cs" Inherits="WCSFContrib.ECommerceCatalog.User.Views.Cart"
    Title="Cart" MasterPageFile="~/Shared/Default.master" %>
<%@ Register Src="~/Product/UserControls/ProductDetails.ascx" TagName="ProductDetails" TagPrefix="uc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="content" ContentPlaceHolderID="DefaultContent" Runat="Server">
		<asp:UpdatePanel ID="UpdatePanel1" runat="server">
	        <ContentTemplate>
	            <br />
	            <div style="text-align: left;">
                    Total: <asp:Label ID="TotalLabel" runat="server" Text="" /></div>
	            <br />
	            
		        <asp:GridView ID="ProductsCartGridView" runat="server" AutoGenerateColumns="False"
			        OnRowCommand="ProductsCartGridView_RowCommand" EmptyDataText="Cart empty.">
			        <Columns>
				        <asp:TemplateField HeaderText="Item ID" Visible="False">
                            <ItemTemplate>
                                <asp:Label ID="ItemIdLabel" runat="server" Text='<%# Eval("Item.ItemId") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <ajax:ConfirmButtonExtender ID="RemoveItemConfirmButtonExtender" runat="server" 
                                                   TargetControlID="RemoveButton"
                                                   ConfirmText="Are you sure you want to remove this product?" />
                                <asp:ImageButton ID="RemoveButton" AlternateText="Remove Product" CommandArgument='<%# Eval("Item.ItemId") %>' CommandName="DeleteCartProduct" runat="server" ImageUrl="~/Images/cart_delete.png" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="120px" />
                            <ItemTemplate>
                                <asp:Image ID="ItemImage" runat="server" ImageUrl='<%# Eval("Item.Image") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
				        <asp:TemplateField HeaderText="Product">
				            <ItemStyle Width="300px" />
                            <ItemTemplate>
                                <asp:Label ID="ItemLabel" runat="server" Text='<%# Eval("Item.Name") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
				        <asp:BoundField DataField="Quantity" HeaderText="Quantity" >
                            <ItemStyle Width="50px" VerticalAlign="Middle" HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="Unit Price">
				            <ItemStyle Width="60px" VerticalAlign="Middle" HorizontalAlign="Right" />
                            <ItemTemplate>
                                <asp:Label ID="UnitPriceLabel" runat="server" Text='<%# "$ " + Eval("Item.Price") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Price">
				            <ItemStyle Width="80px" VerticalAlign="Middle" HorizontalAlign="Right" />
                            <ItemTemplate>
                                <asp:Label ID="PriceLabel" runat="server" Text='<%# "$ " + (Convert.ToDouble(Eval("Item.Price")) * Convert.ToDouble(Eval("Quantity"))) %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                            <ItemTemplate>
                                <asp:ImageButton ID="DetailsProductImageButton" AlternateText="Product Details" ImageAlign="AbsMiddle" ImageUrl="~/Images/details.png" runat="server" CommandArgument='<%# Eval("Item.ItemId") %>' CommandName="ShowProductDetails" />
                            </ItemTemplate>
                        </asp:TemplateField>
			        </Columns>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
		        </asp:GridView>
		        
		        <br />
		        
		        <div style="text-align: right;">
                    <asp:Button ID="CheckoutButton" runat="server" Text="Checkout" OnClick="CheckoutButton_Click" />
                </div>
		        
		        <asp:Label ID="NullControl" runat="server" /> <%-- Non operational control required for the TargetControlID property of popup extender --%>
		        <ajax:ModalPopupExtender ID="DetailsModalPopupExtender" runat="server" 
                                         TargetControlID="NullControl"
                                         PopupControlID="DetailsPopupPanel" 
                                         CancelControlID="CloseButton"
                                         BackgroundCssClass="modalBackground"
                                         DropShadow="true" />
                <asp:Panel ID="DetailsPopupPanel" runat="server" Width="400px" BorderStyle="Outset" CssClass="modalPopup">
                    <div>
                        <table width="100%">
                            <tr>
                                <td align="right">
                                    <asp:Button ID="CloseButton" runat="server" style="text-align:center" Text="X" Width="20px" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <uc1:ProductDetails ID="ProductDetailsUserControl" runat="server" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </asp:Panel>
	        </ContentTemplate>
        </asp:UpdatePanel>
        
        <asp:UpdateProgress ID="ProductsUpdateProgress" runat="server" DisplayAfter="10" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <asp:Image ID="LoadingImage" ImageUrl="../Images/ajax-loader.gif" runat="server" /> Loading...
            </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
